<!DOCTYPE html>
<html lang="en">
<!-- 古韵超市 · 个人信息 -->
<?php
//判断是否非法访问
session_start();
if (!isset($_SESSION['USERINFOS'])) {
    echo "<script>alert('非法访问！');window.location.href='login_reg.html';</script>";
    exit();
}
?>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>古韵超市 · 我的信息</title>
    <link rel="stylesheet" href="bootstrap-5.3.3-dist/bootstrap.min.css">
    <script src="bootstrap-5.3.3-dist/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/u_public.css">
    <link rel="stylesheet" href="css/personal_info.css">
    <script src="js/change-info.js"></script>
</head>

<body>
    <!-- 导航 -->
    <div class="navbar fixed-top">
        <nav class="navbar navbar-expand-lg navbar-light bg-light" id="navbar">
            <div class="container-fluid">
                <div class="logo_div">
                    <img src="img/LOGO.png">
                </div>
                <a class="navbar-brand" href="#">古韵超市网上购物系统</a>
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse"
                    data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
                    aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                        <li class="nav-item">
                            <a class="nav-link" href="../index.php">首页</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="u_all_goods.php">所有商品</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="u_mycart.php">我的购物车</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="u_show_order.php">我的订单</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="u_history_order.php">历史订单</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link active" aria-current="page" href="u_personal_info.php">我的信息</a>
                        </li>
                    </ul>
                    <div class="infobox">
                        当前登录：
                        <?php echo $_SESSION['USERINFOS']['uname']; ?> |
                        <a href="php/logout.php">退出登录</a>
                    </div>
                </div>
            </div>
        </nav>
    </div>
    <main>
        <div class="info_title">
            <h4>我的个人信息</h4>
        </div>
        <div class="base_info">
            <form class="form" action="php/change_info.php" method="post">
                <p class="form_title">基本信息</p>
                <input type="hidden" name="action" value="base">
                <input type="hidden" name="uid" value="<?php echo $_SESSION['USERINFOS']['uid']; ?>">
                <div class="row mb-3">
                    <label for="uname" class="col-sm-3 col-form-label">昵称</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="uname" name="uname" value="<?php echo $_SESSION['USERINFOS']['uname']; ?>" required>
                    </div>
                </div>
                <div class="row mb-3">
                    <label for="uphone" class="col-sm-3 col-form-label">预留电话</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" id="uphone" name="uphone" value="<?php echo $_SESSION['USERINFOS']['uphone']; ?>" required>
                    </div>
                </div>
                <div class="btndiv">
                    <button type="submit" class="btn btn-primary" onclick="return checkBase()">修改信息</button>
                </div>
            </form>
        </div>
        <div class="login_info">
            <form class="form" action="php/change_info.php" method="post">
                <p class="form_title">修改密码</p>
                <input type="hidden" name="action" value="login">
                <input type="hidden" name="uid" value="<?php echo $_SESSION['USERINFOS']['uid']; ?>">
                <div class="row mb-3">
                    <label for="old_pwd" class="col-sm-3 col-form-label">旧密码</label>
                    <div class="col-sm-9">
                        <input type="password" class="form-control" id="old_pwd" name="old_pwd" required>
                    </div>
                </div>
                <div class="row mb-3">
                    <label for="new_pwd" class="col-sm-3 col-form-label">新密码</label>
                    <div class="col-sm-9">
                        <input type="password" class="form-control" id="new_pwd" name="new_pwd" required>
                    </div>
                </div>
                <div class="row mb-3">
                    <label for="rnew_pwd" class="col-sm-3 col-form-label">确认密码</label>
                    <div class="col-sm-9">
                        <input type="password" class="form-control" id="rnew_pwd" required>
                    </div>
                </div>
                <div class="btndiv">
                    <button type="submit" class="btn btn-primary" onclick="return checkPwd()">修改信息</button>
                </div>
            </form>
        </div>
    </main>
    <footer class="fixed-bottom">
        古韵超市网上购物系统© 2025® All Rights Reserved.
    </footer>
</body>

</html>